﻿#ifndef MYWIDGET_H
#define MYWIDGET_H

#include <QWidget>
#include <QThread>
#include <QDebug>

class MyThread;
QT_BEGIN_NAMESPACE
namespace Ui { class MyWidget; }
QT_END_NAMESPACE

class MyWidget : public QWidget
{
    Q_OBJECT

public:
    MyWidget(QWidget *parent = nullptr);
    ~MyWidget();

private slots:
    void on_pb_start_clicked();

    void on_pb_close_clicked();

private:
    Ui::MyWidget *ui;
    MyThread *myThread;
};


class MyThread : public QThread
{
    Q_OBJECT

public:
    MyThread(QWidget *parent = nullptr) {
        Q_UNUSED(parent)
    }
    ~MyThread() {
     qDebug() << "Thread Destory" << endl;
    }
    // 只有这个run()方法在新的线程里面
    void run() override {
        qDebug() << "Thread Start" << endl;
        sleep(5);
        qDebug() << "Thread Close" << endl;
//        deleteLater();
    }
};

#endif // MYWIDGET_H
